#ifndef _NUMA_AWARE_H
#define _NUMA_AWARE_H

#include "syms.h"
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/sched/clock.h>
#include "version.h"
#include "kprobe_prehook.h"
#include <linux/nospec.h>
#include "./include/kernel/sched/sched.h"
#ifdef CONFIG_X86
#include "./include/include/generated/asm-offsets.h"
#include "./include/include//linux/nospec.h"
#endif

#ifdef TK5
#include "./include/kernel/module/internal.h"
#endif
#define PRINT_SYSCALL_NUM 12
#define PRINT_MORE_NUM 12
#define DISK_SDA  8
#define DISK_DM   251
#define DISK_VD   253
#define DISK_NVME 259
#define DISK_HDD  65
#define DISK_HDD1  66
#define DISK_HDD2  67
#define DISK_HDD3  68
#define DISK_SDA_NUM   40
#define DISK_HDD_NUM   60
#define DISK_HDD_SUBNUM  15
#define DISK_DM_NUM    16
#define DISK_VD_NUM    80
#define DISK_NVME_NUM  80
#define DISK_TOTAL_NUM (DISK_SDA_NUM + DISK_HDD_NUM + DISK_DM_NUM + DISK_VD_NUM + DISK_NVME_NUM)
#define TRACK_SYSCALL_NUM (PRINT_SYSCALL_NUM + PRINT_MORE_NUM + DISK_TOTAL_NUM)

#define STAT_SYSCALL_TYPE 0X01
#define STAT_FUNC_TYPE 0X02
#define STAT_PAGEFAULT_TYPE 0X04

struct func_latency {
	unsigned long nr;
	unsigned long num;
	unsigned long latency;
	unsigned long block_latency;
	char func[256];
};
extern unsigned int sysctl_module_enable;
extern unsigned int sysctl_module_debug;
extern unsigned int sysctl_module_disable;
extern unsigned int sysctl_module_data;
extern unsigned int sysctl_module_print;
extern struct func_latency sysctl_data[TRACK_SYSCALL_NUM];

extern struct page *stat_alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid,
													 nodemask_t *nodemask);
extern struct task_struct * stat_pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags_stat *rf);
extern blk_qc_t stat_submit_bio(struct bio *bio);
extern void stat_bio_endio(struct bio *bio);
extern void *stat__kmalloc(size_t size, gfp_t flags);
extern void *stat__kmalloc_node(size_t size, gfp_t flags, int node);
extern void *stat_kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags);
#ifdef TK5
bool stat_blk_mq_dispatch_rq_list(struct blk_mq_hw_ctx *hctx, struct list_head *list,
       unsigned int nr_budgets);
#else
extern bool stat_blk_mq_get_driver_tag(struct request *rq);
#endif
extern int stat_access_remote_vm(struct mm_struct *mm, unsigned long addr,
         void *buf, int len, unsigned int gup_flags);
extern void stat_stat_syscall_enter(struct kret_data *data);
extern void stat_stat_syscall_exit(unsigned long nr, struct kret_data *data);
extern void stat_sched_rqm_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next);
extern struct rq *stat_finish_task_switch(struct task_struct *prev);

#ifdef CONFIG_X86_64
extern void stat_do_syscall_64(unsigned long nr, struct pt_regs *regs);
#endif

extern void stat_syscall_return_slowpath(struct pt_regs *regs);
extern void stat_func_enter(struct kret_data *data);
extern void stat_func_exit(struct kret_data *data);
extern void set_sys_nr(unsigned long nr);
extern unsigned long get_sys_nr(void);
extern void set_func_type(int pos);
extern unsigned long get_func_type(void);
extern void clr_func_type(int pos);
extern void unload_disable_module(void);
extern void stat_do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
extern bool module_is_enable(void);
#ifdef TK5
extern vm_fault_t stat_handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
                unsigned int flags, struct pt_regs *regs);
extern void stat_psi_task_switch(struct task_struct *prev, struct task_struct *next, bool sleep);
#endif
extern void stat_rcu_note_context_switch(bool preempt);
extern int data_init(void);
extern int data_exit(void);

#endif
